package com.accesshollywood.grfxOrdering.panels;

import java.awt.Component;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.HashMap;

import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListModel;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.SpringLayout;
import javax.swing.SwingConstants;
import javax.swing.border.EtchedBorder;

import org.jdesktop.swingx.HorizontalLayout;
import org.jdesktop.swingx.JXPanel;
import org.jdesktop.swingx.VerticalLayout;

import com.accesshollywood.SQL.GrfxDateTime;
import com.accesshollywood.components.EditableComboBox;
import com.accesshollywood.components.EditableListWithPopup.EditActionListener;
import com.accesshollywood.components.EditableTextWithPopup;
import com.accesshollywood.components.IconUtil;
import com.accesshollywood.components.LabelWithPopup;
import com.accesshollywood.components.MultiLabelButton;
import com.accesshollywood.grfxOrdering.GRFXOrdersMain;
import com.accesshollywood.grfxOrdering.basics.BLOCK;
import com.accesshollywood.grfxOrdering.basics.Colors;
import com.accesshollywood.grfxOrdering.basics.Destinations;
import com.accesshollywood.grfxOrdering.basics.GraphicTypes;
import com.accesshollywood.grfxOrdering.basics.ShowNames;
import com.accesshollywood.grfxOrdering.basics.Users;
import com.accesshollywood.indexables.Destination;
import com.accesshollywood.indexables.GraphicType;
import com.accesshollywood.indexables.GrfxOrder;
import com.accesshollywood.indexables.ShowName;
import com.accesshollywood.indexables.User;
import com.accesshollywood.notifications.EmailAlert;
import com.accesshollywood.prefs.Prefs;
import com.accesshollywood.trace.Trace;

public class OrderHeaderPanel extends JXPanel {
	public JComponent				parent;
	private LabelWithPopup			txt_show;
	private LabelWithPopup			txt_Block;
	private LabelWithPopup			txt_graphicType;
	private LabelWithPopup			txt_destination;
	// private EditableOneColumnTable txt_summary;
	private EditableTextWithPopup	txt_summary;
	private MultiLabelButton		btn_dueDate;
	private JLabel					txt_idOrder;
	private JButton					btn_assignedUser;
	private EditableComboBox		comboBox_assignedUsers;
	// private JComboBox comboBox_jobs;
	private JLabel					btn_print;
	private GrfxOrder				model;
	private JSeparator				separator;
	private Component				horizontalGlue;
	private Component				horizontalGlue_1;

	DefaultComboBoxModel			assignedUsersModel;
	DefaultComboBoxModel			jobModel;

	private static User				oldUser		= null;

	protected static boolean		firstPass	= true;

	public OrderHeaderPanel(GrfxOrder currOrder, JComponent parent) {
		setupPanel(currOrder);

		btn_dueDate.doClick();

		this.getComponents();
	}

	public void addPopups(final GrfxOrder currOrder) {
		btn_dueDate.popup.addMenuItem("Edit", new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				final JDialog dueDateDialog = new JDialog(GRFXOrdersMain.gui, Dialog.ModalityType.DOCUMENT_MODAL);
				dueDateDialog.setBounds(100, 100, 250, 130);
				dueDateDialog.setLocationRelativeTo(GRFXOrdersMain.gui);
				dueDateDialog.setLayout(new VerticalLayout());
				final DueDatePanel dueDatePanel = new DueDatePanel();
				dueDateDialog.add(dueDatePanel);

				JPanel buttonPanel = new JPanel();
				buttonPanel.setLayout(new HorizontalLayout());
				JButton btn_OK = new JButton("OK");
				btn_OK.addActionListener(new ActionListener() {
					@Override
					public void actionPerformed(ActionEvent arg0) {
						// SQLDate newDate = new SQLDate(dueDatePanel.dateTimePicker);
						GrfxDateTime newDate = new GrfxDateTime(dueDatePanel.dateTimePicker);
						currOrder.setDeepAccess(true);
						currOrder.setDueDate(newDate);
						currOrder.setDeepAccess(false);
						dueDateDialog.dispose();// .setVisible(false);
					}
				});
				JButton btn_Cancel = new JButton("CANCEL");
				btn_Cancel.addActionListener(new ActionListener() {
					@Override
					public void actionPerformed(ActionEvent arg0) {
						dueDateDialog.setVisible(false);
					}
				});

				buttonPanel.add(btn_OK);
				buttonPanel.add(btn_Cancel);

				dueDateDialog.add(buttonPanel);

				dueDateDialog.setVisible(true);
			}
		});

		setupBlockEdit(currOrder, txt_Block);
		setupGraphicTypeEdit(currOrder, txt_graphicType);
		setupDestinationEdit(currOrder, txt_destination);
		// txt_summary.popup.addMenuItem("Edit", txt_summary.new EditActionListener());
		setupShowEdit(currOrder, txt_show);
	}

	public void setupPanel(final GrfxOrder currOrder) {
		setMaximumSize(new Dimension(32767, 20));
		setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
		setAlignmentX(LEFT_ALIGNMENT);

		btn_dueDate = new MultiLabelButton(Prefs.PixelSize.deadline.get());
		btn_dueDate.setModel(new String[] { "Due Date:", "Time Left:" });
		btn_dueDate.setAction(this, "com.accesshollywood.grfxOrdering.panels.OrderHeaderPanel", "toggleDateDisplayFormat");
		btn_dueDate.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
		btn_dueDate.setPreferredSize(new Dimension(130, 20));
		btn_dueDate.setMinimumSize(new Dimension(130, 20));
		btn_dueDate.setMaximumSize(new Dimension(130, 20));
		btn_dueDate.setAlignmentX(LEFT_ALIGNMENT);
		add(btn_dueDate);

		txt_Block = new LabelWithPopup();
		txt_Block.setHorizontalAlignment(SwingConstants.CENTER);
		txt_Block.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
		txt_Block.setFont(new Font(txt_Block.getFont().getFontName(), Font.BOLD, Prefs.PixelSize.block.get()));
		txt_Block.setAlignmentX(Component.RIGHT_ALIGNMENT);
		txt_Block.setPreferredSize(new Dimension(25, 20));
		txt_Block.setMinimumSize(new Dimension(25, 20));
		txt_Block.setMaximumSize(new Dimension(25, 20));
		add(txt_Block);

		txt_graphicType = new LabelWithPopup();
		txt_graphicType.setFont(new Font(txt_graphicType.getFont().getName(), txt_graphicType.getFont().getStyle(), Prefs.PixelSize.graphicType.get()));
		txt_graphicType.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
		txt_graphicType.setHorizontalAlignment(SwingConstants.CENTER);
		txt_graphicType.setPreferredSize(new Dimension(80, 20));
		txt_graphicType.setMinimumSize(new Dimension(80, 20));
		txt_graphicType.setMaximumSize(new Dimension(80, 20));
		txt_graphicType.setAlignmentX(LEFT_ALIGNMENT);
		add(txt_graphicType);

		txt_destination = new LabelWithPopup();
		txt_destination.setFont(new Font(txt_destination.getFont().getName(), txt_destination.getFont().getStyle(), Prefs.PixelSize.destination.get()));
		txt_destination.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
		txt_destination.setHorizontalAlignment(SwingConstants.CENTER);
		txt_destination.setPreferredSize(new Dimension(80, 20));
		txt_destination.setMinimumSize(new Dimension(80, 20));
		txt_destination.setMaximumSize(new Dimension(80, 20));
		txt_destination.setAlignmentX(LEFT_ALIGNMENT);
		add(txt_destination);

		txt_summary = new EditableTextWithPopup(this, Prefs.PixelSize.summary.get());
		txt_summary.setPreferredSize(new Dimension(190, 20));
		txt_summary.setMinimumSize(new Dimension(190, 20));
		txt_summary.setMaximumSize(new Dimension(190, 20));
		txt_summary.setOpaque(false);
		add(txt_summary);

		txt_show = new LabelWithPopup();
		txt_show.setFont(new Font(txt_show.getFont().getName(), txt_show.getFont().getStyle(), Prefs.PixelSize.show.get()));
		txt_show.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
		txt_show.setHorizontalAlignment(SwingConstants.CENTER);
		txt_show.setPreferredSize(new Dimension(40, 20));
		txt_show.setMinimumSize(new Dimension(40, 20));
		txt_show.setMaximumSize(new Dimension(40, 20));
		txt_show.setAlignmentX(Component.RIGHT_ALIGNMENT);
		add(txt_show);

		comboBox_assignedUsers = new EditableComboBox();
		comboBox_assignedUsers.setPreferredSize(new Dimension(150, 20));
		comboBox_assignedUsers.setMinimumSize(new Dimension(150, 20));
		comboBox_assignedUsers.setMaximumSize(new Dimension(150, 20));
		comboBox_assignedUsers.setAlignmentX(Component.RIGHT_ALIGNMENT);
		add(comboBox_assignedUsers);

		txt_idOrder = new JLabel();
		txt_idOrder.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
		txt_idOrder.setFont(new Font("Tahoma", Font.BOLD, Prefs.PixelSize.orderNum.get()));
		txt_idOrder.setHorizontalAlignment(SwingConstants.CENTER);
		txt_idOrder.setAlignmentX(Component.RIGHT_ALIGNMENT);
		txt_idOrder.setPreferredSize(new Dimension(90, 20));
		txt_idOrder.setMinimumSize(new Dimension(90, 20));
		txt_idOrder.setMaximumSize(new Dimension(90, 20));
		add(txt_idOrder);

		ImageIcon printIcon = IconUtil.createImageIcon("res/icons/print.jpg", "Print");
		btn_print = new JLabel(printIcon);
		btn_print.setPreferredSize(new Dimension(26, 20));
		btn_print.setMinimumSize(new Dimension(26, 20));
		btn_print.setMaximumSize(new Dimension(26, 20));
		btn_print.addMouseListener(new PrintClickListener());
		add(btn_print);

		setModel(currOrder);
		btn_dueDateRepaint();
		setLayout(setupSpringLayout());
		displayJob();

		try {
			setupAssignedUsersPopup();
		} catch (Exception e) {
			e.printStackTrace();
		}

		comboBox_assignedUsers.addItemListener(new ItemListener() {
			public void itemStateChanged(ItemEvent arg0) {
				// comboBox_assignedUsers.setEditable(true);
				// assignmentsSnapBack();
				/*
				 * switch (arg0.getStateChange()) {
				 * case ItemEvent.DESELECTED:
				 * unAssignUser((User) arg0.getItem());
				 * break;
				 * case ItemEvent.SELECTED:
				 * assignUser();
				 * break;
				 * }
				 */
			}
		});

		if (Users.currentUser.canEditOrder(currOrder)) {
			addPopups(currOrder);
		}
	}

	public void setupAssignedUsersPopup() throws SecurityException, NoSuchFieldException {
		if (model != null) {
			if (Users.currentUser.canEditOrderByDepartment(model, User.class.getDeclaredField("isArtist"))) {
				JMenu artistMenu = comboBox_assignedUsers.popup.addMenu("Artist");
				for (int i = 0; i < Users.artistUsers.getSize(); i++) {
					final int index = i;
					if (Users.artistUsers.getElementAt(i) instanceof User) {
						User currUser = (User) Users.artistUsers.getElementAt(i);
						comboBox_assignedUsers.popup.addMenuItem(currUser.getFullName(), artistMenu, new ActionListener() {
							@Override
							public void actionPerformed(ActionEvent e) {
								model.setArtist((User) Users.artistUsers.getElementAt(index));
								Trace.info(index);
							}
						});
					}
				}
			}

			if (Users.currentUser.canEditOrderByDepartment(model, User.class.getDeclaredField("isResearch"))) {
				JMenu researchMenu = comboBox_assignedUsers.popup.addMenu("Research");
				for (int i = 0; i < Users.researchUsers.getSize(); i++) {
					final int index = i;
					if (Users.researchUsers.getElementAt(i) instanceof User) {
						User currUser = (User) Users.researchUsers.getElementAt(i);
						comboBox_assignedUsers.popup.addMenuItem(currUser.getFullName(), researchMenu, new ActionListener() {
							@Override
							public void actionPerformed(ActionEvent e) {
								model.setResearcher((User) Users.researchUsers.getElementAt(index));
								Trace.info(index);
							}
						});
					}
				}
			}

			if (Users.currentUser.canEditOrderByDepartment(model, User.class.getDeclaredField("isPhotoEdit"))) {
				JMenu photoEditMenu = comboBox_assignedUsers.popup.addMenu("PhotoEdit");
				for (int i = 0; i < Users.photoEditUsers.getSize(); i++) {
					final int index = i;
					if (Users.photoEditUsers.getElementAt(i) instanceof User) {
						User currUser = (User) Users.photoEditUsers.getElementAt(i);
						comboBox_assignedUsers.popup.addMenuItem(currUser.getFullName(), photoEditMenu, new ActionListener() {
							@Override
							public void actionPerformed(ActionEvent e) {
								model.setPhotoEdit((User) Users.photoEditUsers.getElementAt(index));
								Trace.info(index);
							}
						});
					}
				}
			}

			if (Users.currentUser.canEditOrderByDepartment(model, User.class.getDeclaredField("isFootage"))) {
				JMenu footageMenu = comboBox_assignedUsers.popup.addMenu("Footage");
				for (int i = 0; i < Users.footageUsers.getSize(); i++) {
					final int index = i;
					if (Users.footageUsers.getElementAt(i) instanceof User) {
						User currUser = (User) Users.footageUsers.getElementAt(i);
						comboBox_assignedUsers.popup.addMenuItem(currUser.getFullName(), footageMenu, new ActionListener() {
							@Override
							public void actionPerformed(ActionEvent e) {
								model.setFootage((User) Users.footageUsers.getElementAt(index));
								Trace.info(index);
							}
						});
					}
				}
			}

			if (Users.currentUser.canEditOrderByDepartment(model, User.class.getDeclaredField("isLegal"))) {
				JMenu legalMenu = comboBox_assignedUsers.popup.addMenu("Legal");
				for (int i = 0; i < Users.legalUsers.getSize(); i++) {
					final int index = i;
					if (Users.legalUsers.getElementAt(i) instanceof User) {
						User currUser = (User) Users.legalUsers.getElementAt(i);
						comboBox_assignedUsers.popup.addMenuItem(currUser.getFullName(), legalMenu, new ActionListener() {
							@Override
							public void actionPerformed(ActionEvent e) {
								model.setLegal((User) Users.legalUsers.getElementAt(index));
								Trace.info(index);
							}
						});
					}
				}
			}

			if (Users.currentUser.canEditOrderByDepartment(model, User.class.getDeclaredField("isProducer"))) {
				JMenu producerMenu = comboBox_assignedUsers.popup.addMenu("Producer");
				for (int i = 0; i < Users.producerUsers.getSize(); i++) {
					final int index = i;
					if (Users.producerUsers.getElementAt(i) instanceof User) {
						User currUser = (User) Users.producerUsers.getElementAt(i);
						comboBox_assignedUsers.popup.addMenuItem(currUser.getFullName(), producerMenu, new ActionListener() {
							@Override
							public void actionPerformed(ActionEvent e) {
								model.setProducer((User) Users.producerUsers.getElementAt(index));
								Trace.info(index);
							}
						});
					}
				}
			}

			if (Users.currentUser.canEditOrderByDepartment(model, User.class.getDeclaredField("isOrderer"))) {
				JMenu orderedByMenu = comboBox_assignedUsers.popup.addMenu("OrderedBy");
				for (int i = 0; i < Users.orderedByUsers.getSize(); i++) {
					final int index = i;
					if (Users.orderedByUsers.getElementAt(i) instanceof User) {
						User currUser = (User) Users.orderedByUsers.getElementAt(i);
						comboBox_assignedUsers.popup.addMenuItem(currUser.getFullName(), orderedByMenu, new ActionListener() {
							@Override
							public void actionPerformed(ActionEvent e) {
								model.setOrderedBy((User) Users.orderedByUsers.getElementAt(index));
								Trace.info(index);
							}
						});
					}
				}
			}
		}
	}

	public void refresh() {
		this.setModel(model);
		displayJob();
		revalidate();
		repaint();
	}

	public void setupBlockEdit(final GrfxOrder currOrder, final LabelWithPopup label) {
		for (final BLOCK currBlock : BLOCK.values()) {
			label.popup.addMenuItem(currBlock.str, new ActionListener() {
				@Override
				public void actionPerformed(ActionEvent arg0) {
					currOrder.setDeepAccess(true);
					currOrder.setBlock(currBlock);
					currOrder.setDeepAccess(false);
					label.setText(currBlock.str);
				}
			});
		}
	}

	public void setupGraphicTypeEdit(final GrfxOrder currOrder, final LabelWithPopup label) {
		DefaultListModel graphicTypes;

		switch (currOrder.getShowName().getId()) {
			case 1:
				graphicTypes = GraphicTypes.AHGraphicTypesModel;
				break;
			case 2:
				graphicTypes = GraphicTypes.LIVEGraphicTypesModel;
				break;
			default:
				graphicTypes = GraphicTypes.AHGraphicTypesModel;
				break;
		}

		for (final Object currType : graphicTypes.toArray()) {
			label.popup.addMenuItem(((GraphicType) currType).getName(), new ActionListener() {

				@Override
				public void actionPerformed(ActionEvent arg0) {
					currOrder.setDeepAccess(true);
					currOrder.setGraphicType((GraphicType) currType);
					currOrder.setDeepAccess(false);
					label.setText(((GraphicType) currType).getName());
				}

			});
		}
	}

	public void setupDestinationEdit(final GrfxOrder currOrder, final LabelWithPopup label) {
		for (final Destination currDestination : Destinations.allDestinations.values()) {
			label.popup.addMenuItem(currDestination.getName(), new ActionListener() {
				@Override
				public void actionPerformed(ActionEvent arg0) {
					currOrder.setDeepAccess(true);
					currOrder.setDestination(currDestination);
					currOrder.setDeepAccess(false);
					label.setText(currDestination.getName());
				}
			});
		}
	}

	public void setupShowEdit(final GrfxOrder currOrder, final LabelWithPopup label) {
		HashMap<Integer, ShowName> showList = ShowNames.allShowNames;

		for (final ShowName currShow : showList.values()) {
			label.popup.addMenuItem(currShow.name, new ActionListener() {

				@Override
				public void actionPerformed(ActionEvent arg0) {
					currOrder.setDeepAccess(true);
					currOrder.setShowName(currShow);
					currOrder.setDeepAccess(false);
					label.setText(currShow.nickName);
				}

			});
		}
	}

	public SpringLayout setupSpringLayout() {
		SpringLayout springLayout = new SpringLayout();
		springLayout.putConstraint(SpringLayout.WEST, btn_dueDate, 20, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.WEST, txt_Block, 5, SpringLayout.EAST, btn_dueDate);
		springLayout.putConstraint(SpringLayout.WEST, txt_graphicType, 5, SpringLayout.EAST, txt_Block);
		springLayout.putConstraint(SpringLayout.WEST, txt_destination, 5, SpringLayout.EAST, txt_graphicType);
		springLayout.putConstraint(SpringLayout.WEST, txt_summary, 5, SpringLayout.EAST, txt_destination);
		// springLayout.putConstraint(SpringLayout.SOUTH, txt_summary, 1, SpringLayout.SOUTH, this);
		springLayout.putConstraint(SpringLayout.EAST, btn_print, 2, SpringLayout.EAST, this);
		springLayout.putConstraint(SpringLayout.EAST, txt_idOrder, 2, SpringLayout.WEST, btn_print);
		springLayout.putConstraint(SpringLayout.EAST, comboBox_assignedUsers, -5, SpringLayout.WEST, txt_idOrder);
		springLayout.putConstraint(SpringLayout.EAST, txt_show, -5, SpringLayout.WEST, comboBox_assignedUsers);
		springLayout.putConstraint(SpringLayout.SOUTH, this, 0, SpringLayout.SOUTH, btn_dueDate);
		return springLayout;
	}

	public JSeparator addSeparator() {
		separator = new JSeparator();
		separator.setMaximumSize(new Dimension(32767, 20));
		separator.setOrientation(SwingConstants.VERTICAL);
		separator.setAlignmentX(Component.LEFT_ALIGNMENT);
		add(separator);
		return separator;
	}

	public void displayJob() {
		assignedUsersModel = new DefaultComboBoxModel();

		assignedUsersModel.addElement("ART: " + model.getArtist().getFullName());
		assignedUsersModel.addElement("RES: " + model.getResearcher().getFullName());
		assignedUsersModel.addElement("PHTO: " + model.getPhotoEdit().getFullName());
		assignedUsersModel.addElement("FOOT: " + model.getFootage().getFullName());
		assignedUsersModel.addElement("LEG: " + model.getLegal().getFullName());
		assignedUsersModel.addElement("PROD: " + model.getProducer().getFullName());
		assignedUsersModel.addElement("ORD: " + model.getOrderedBy().getFullName());

		comboBox_assignedUsers.setModel(assignedUsersModel);
	}

	public void unAssignUser(User oldUser) {
		EmailAlert.orderUnAssigned(model, oldUser, Users.currentUser);
	}

	public void assignmentsSnapBack() {
		// comboBox_assignedUsers.setEnabled(true);
		if (!Users.currentUser.isAdmin()) {
			if (Users.currentUser.isArtist() && comboBox_assignedUsers.getSelectedIndex() != 0) {
				comboBox_assignedUsers.setSelectedIndex(0);
			}
			if (Users.currentUser.isResearch() && comboBox_assignedUsers.getSelectedIndex() != 1) {
				comboBox_assignedUsers.setSelectedIndex(1);
			}
			if (Users.currentUser.isPhotoEdit() && comboBox_assignedUsers.getSelectedIndex() != 2) {
				comboBox_assignedUsers.setSelectedIndex(2);
			}
			if (Users.currentUser.isFootage() && comboBox_assignedUsers.getSelectedIndex() != 3) {
				comboBox_assignedUsers.setSelectedIndex(3);
			}
			if (Users.currentUser.isLegal() && comboBox_assignedUsers.getSelectedIndex() != 4) {
				comboBox_assignedUsers.setSelectedIndex(4);
			}
			if (Users.currentUser.isProducer() && comboBox_assignedUsers.getSelectedIndex() != 5) {
				comboBox_assignedUsers.setSelectedIndex(5);
			}
			if (Users.currentUser.isOrderer() && comboBox_assignedUsers.getSelectedIndex() != 6) {
				comboBox_assignedUsers.setSelectedIndex(6);
			}
		}
		// if(!Users.currentUser.isAdmin){
		// comboBox_assignedUsers.setEnabled(false);
		// }
	}

	public void setModel(GrfxOrder model) {
		this.model = model;
		if (model != null) {
			txt_show.setText(model.getShowName().nickName);
			txt_Block.setText(model.getBlock().str);
			txt_graphicType.setText((model.getGraphicType() != null) ? model.getGraphicType().getName() : "NULL");
			txt_destination.setText(model.getDestination().getName());
			// ((EditableListModel)txt_summary.getModel()).clear();
			// ((EditableListModel)txt_summary.getModel()).addElement(model.getSummary());
			txt_summary.setText(model.getSummary());
			// txt_summary.setText(model.getSummary());
			txt_idOrder.setText(model.getId() + "");
			// setAssignedUsersModel(model);
			displayJob();
			btn_dueDateRepaint();
		}
	}

	public void setAssignedUsersModel(GrfxOrder model) {
		// assignedUsersModel.removeAllElements();
		jobModel = new DefaultComboBoxModel();
		jobModel.addElement("Artist: ");
		jobModel.addElement("Res: ");
		jobModel.addElement("Photo: ");
		jobModel.addElement("Footage: ");
		jobModel.addElement("Legal: ");
		jobModel.addElement("Prod: ");
		jobModel.addElement("Orderer: ");

		// assignedUsersModel.removeAllElements();
		/*
		 * assignedUsersModel = new DefaultComboBoxModel();
		 * assignedUsersModel.addElement(model.artist.fullName());
		 * assignedUsersModel.addElement(model.researcher.fullName());
		 * assignedUsersModel.addElement(model.photoEdit.fullName());
		 * assignedUsersModel.addElement(model.footage.fullName());
		 * assignedUsersModel.addElement(model.legal.fullName());
		 * assignedUsersModel.addElement(model.producer.fullName());
		 * assignedUsersModel.addElement(model.orderedBy.fullName());
		 */

		// comboBox_jobs.setModel(jobModel);
		// comboBox_jobs.revalidate();
		// comboBox_jobs.repaint();

		// comboBox_assignedUsers.setModel(assignedUsersModel);
		// comboBox_assignedUsers.revalidate();
		// comboBox_assignedUsers.repaint();
		// assignmentsSnapBack();
	}

	public void toggleDateDisplayFormat() {
		switch (btn_dueDate.getSelectedIndex()) {
			case 0:
				btn_dueDate.setText(model.getDueDate().toString());
				break;
			case 1:
				btn_dueDate.setText(model.getDueDate().toRemainingString());
				break;
		}
	}

	public void btn_dueDateRepaint() {
		toggleDateDisplayFormat();
		if (model.getDueDate().isPast()) {
			btn_dueDate.setBackground(Colors.getColor(Colors.OVERDUE));
		} else {
			btn_dueDate.setBackground(Colors.getColor(Colors.NOT_DUE_YET));
		}
	}

	public class PrintClickListener implements MouseListener {

		@Override
		public void mouseClicked(MouseEvent arg0) {
			model.print();
		}

		@Override
		public void mouseEntered(MouseEvent arg0) {
		}

		@Override
		public void mouseExited(MouseEvent arg0) {
		}

		@Override
		public void mousePressed(MouseEvent arg0) {
		}

		@Override
		public void mouseReleased(MouseEvent arg0) {
		}

	}
}
